package com.github.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ConfigController
 * @Description TODO
 * @Author shuang669539827@163.com
 * @Date2019/1/22 11:27
 * @Version v1.0
 **/
@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    /**动态获取配置**/
    @Value("${user.name}")
    private String name;

    @Value("${user.age}")
    private int age;

    @RequestMapping("/get")
    public boolean get() {
        return useLocalCache;
    }

    @RequestMapping("/name")
    public String getstr(){
        return name +age;
    }

}
